package com.ddy.test.inputStream;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class FileWriter {

    public static void main(String[] args) {

    }

    public static void write(InputStream inputStream,String file) throws IOException {
    FileOutputStream downloadFile = new FileOutputStream(file);

        int index;
        byte[] bytes = new byte[1024];
        while ((index = inputStream.read(bytes)) != -1) {
            downloadFile.write(bytes, 0, index);
            downloadFile.flush();
        }
        downloadFile.close();
        inputStream.close();

    }
}
